home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 076-100 / disk_098 / thai / thai.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  3KB  |  140 lines

  1.  
  2. #include "quiz.h"
  3.  
  4.  
  5. extern APTR            OpenLibrary ();
  6. struct TextFont *    OpenDiskFont ();
  7. LONG                IntuiTextLength ();
  8.  
  9. struct TextAttr        thai_textattr;
  10.  
  11.  
  12. #define TG_BASEX    4
  13. #define TG_BASEY    12
  14. #define TG_KWIDTH    632
  15. #define TG_WIDTH    16
  16. #define TG_HEIGHT    26
  17. #define TG_GAP        6
  18.  
  19.  
  20. struct Gadget        thai_gadget[ TC_MAX_CHAR ];
  21. struct IntuiText    thai_gtext[ TC_MAX_CHAR ];
  22. UBYTE                thai_gtbuf[ TC_MAX_CHAR * 3 ];
  23.  
  24.  
  25. init_thai_keyboard ()
  26. {
  27.     int c , i , x , y , width;
  28.     register struct IntuiText *ip;
  29.     register struct Gadget *gp;
  30.     struct RastPort rp;
  31.  
  32.  
  33.     i = 0;
  34.     x = TG_BASEX;
  35.     y = TG_BASEY;
  36.     for ( i = 0; i < TC_MAX_CHAR; i++ ) {
  37.         if ( isthai ( i ) ) {
  38.  
  39.             ip = &thai_gtext[ i ];
  40.             ip->FrontPen = FP;
  41.             ip->BackPen = BP;
  42.             ip->DrawMode = JAM1;
  43.             ip->TopEdge = 2;
  44.             ip->ITextFont = &thai_textattr;
  45.             ip->IText = &thai_gtbuf[ i * 3 ];
  46.             if ( isreverse(i) ) {
  47.                 thai_gtbuf[ i * 3 + 0 ] = TC_AW;
  48.                 thai_gtbuf[ i * 3 + 1 ] = i;
  49.                 thai_gtbuf[ i * 3 + 2 ] = 0;
  50.             }
  51.             else {
  52.                 thai_gtbuf[ i * 3 + 0 ] = i;
  53.                 thai_gtbuf[ i * 3 + 1 ] = 0;
  54.             }
  55.             ip->NextText = NULL;
  56.             ip->LeftEdge = 0;
  57.  
  58.             width = IntuiTextLength ( ip );
  59.  
  60.             ip->LeftEdge = TG_GAP / 2;
  61.  
  62.             if ( x + width + TG_GAP >= TG_BASEX + TG_KWIDTH ) {
  63.                 x = TG_BASEX;
  64.                 y += TG_HEIGHT;
  65.             }
  66.  
  67.             gp = &thai_gadget[i];
  68.             gp->NextGadget = NULL;
  69.             gp->LeftEdge = x;
  70.             x += width + TG_GAP;
  71.             gp->TopEdge = y;
  72.             gp->Width = width + TG_GAP;
  73.             gp->Height = TG_HEIGHT;
  74.             gp->Flags = GADGHCOMP
  75. #ifdef USE_ON_OFF
  76.                 | GADGDISABLED
  77. #endif
  78.                 ;
  79.             gp->Activation = RELVERIFY;
  80.             gp->GadgetType = BOOLGADGET;
  81.             gp->GadgetRender = NULL;
  82.             gp->SelectRender = NULL;
  83.             gp->MutualExclude = 0;
  84.             gp->SpecialInfo = NULL;
  85.             gp->GadgetID = i;
  86.             gp->UserData = NULL;
  87.             gp->GadgetText = ip;
  88.             AddGadget ( window , gp , (LONG)-1 );
  89.         }
  90.     }
  91.     RefreshGadgets ( window->FirstGadget , window , (LONG)NULL );
  92. }
  93.  
  94.  
  95. off_thai_keyboard ()
  96. {
  97. #ifdef USE_ON_OFF
  98.     int i;
  99.  
  100.     for ( i = 0; i < TC_MAX_CHAR; i++ )
  101.         if ( isthai ( i ) )
  102.             OffGadget ( &thai_gadget[i] , window , (LONG)NULL );
  103. #endif
  104. }
  105.  
  106.  
  107. on_thai_keyboard ()
  108. {
  109. #ifdef USE_ON_OFF
  110.     int i;
  111.  
  112.     for ( i = 0; i < TC_MAX_CHAR; i++ )
  113.         if ( isthai ( i ) )
  114.             OnGadget ( &thai_gadget[i] , window , (LONG)NULL );
  115. #endif
  116. }
  117.  
  118.  
  119. redraw_thai ( field )
  120. int field;        /* TW_ENTRY or TS_ENTRY */
  121. {
  122.     static struct IntuiText itext =
  123.         { FP , BP , JAM1 , 0 , 0 , NULL , NULL , NULL };
  124.  
  125.     itext.ITextFont = &thai_textattr;
  126.     SetAPen ( window->RPort , (LONG)0 );
  127.     if ( field == TW_ENTRY ) {
  128.         itext.IText = (UBYTE*) screen_word.thai;
  129.         RectFill ( window->RPort , (LONG) TWBASEX , (LONG) TWBASEY ,
  130.             (LONG) TWBASEX + TWWIDTH - 1 , (LONG)TWBASEY + TWHEIGHT - 1 );
  131.         PrintIText ( window->RPort , &itext , (LONG)TWBASEX , (LONG)TWBASEY );
  132.     }
  133.     else {
  134.         itext.IText = (UBYTE*) screen_sentence.thai;
  135.         RectFill ( window->RPort , (LONG) TSBASEX , (LONG) TSBASEY ,
  136.             (LONG) TSBASEX + TSWIDTH - 1 , (LONG)TSBASEY + TSHEIGHT - 1 );
  137.         PrintIText ( window->RPort , &itext , (LONG)TSBASEX , (LONG)TSBASEY );
  138.     }
  139. }
  140.